package com.jycrm.presentation.pages;

import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterChain;
import java.io.IOException;
import javax.servlet.http.*;

public class EncodingFilter implements Filter {
	private String encoding;

	public EncodingFilter() {
	}

	public void init(FilterConfig fconfig) throws ServletException {
		encoding = fconfig.getInitParameter("charset");
	}

	public void doFilter(ServletRequest req, ServletResponse resp,
			FilterChain fchain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) req;
		request.setCharacterEncoding(encoding);
		fchain.doFilter(req, resp);
	}

	public void destroy() {
	}
}
